package app.caihan.wanandroid.ui.article

import app.caihan.wanandroid.R
import app.caihan.wanandroid.model.bean.Article
import app.caihan.wanandroid.databinding.ItemArticleItemBinding
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder

/**
 *
 *
 * @author Seven-C
 * @date 2020/8/1
 */
class ArticleListAdapter :
    BaseQuickAdapter<Article, BaseDataBindingHolder<ItemArticleItemBinding>>(R.layout.item_article_item) {
    override fun convert(holder: BaseDataBindingHolder<ItemArticleItemBinding>, item: Article) {
        // 获取 Binding
        val binding: ItemArticleItemBinding? = holder.dataBinding

        //let 操作符,如果对象的值不为空，则允许执行这个方法等同于if(binding != null),it表示他自己
        binding?.let {
            it.itemObj = item
            it.executePendingBindings()
        }
    }
}